//
//  YDOAApplyDetialCell.swift
//  YDOAProduct
//
//  Created by YDWY on 2017/6/2.
//  Copyright © 2017年 Allen. All rights reserved.
//

import UIKit
import Kingfisher
class YDOAApplyDetialCell: UITableViewCell {

    
    
    
    
    @IBOutlet weak var numLab: UILabel!
    @IBOutlet weak var picView: UIImageView!
    @IBOutlet weak var nameLab: UILabel!
    @IBOutlet weak var totalNumLab: UILabel!
    @IBOutlet weak var applyNumLab: UITextField!
    

    
    var callback : ((_ model : ApplyModel)->Swift.Void)? = nil
    
    
    
    var model : ApplyModel!{
        didSet{
            numLab.text = "\(model.num)"
           
            picView.kf.setImage(with:  URL(string: model.pic))
            nameLab.text = model.name
            totalNumLab.text = "\(model.count)"
            applyNumLab.text = model.applyNum
            applyNumLab.delegate = self
            
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        
        
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}



extension YDOAApplyDetialCell : UITextFieldDelegate {

    func textFieldDidEndEditing(_ textField: UITextField) {
        
        let model = self.model
        guard let applynum = textField.text else { return
            
        }
        model?.applyNum = applynum
        if callback != nil {
            callback!(model!)
        }
    }
}

